from django.http import HttpResponse
from django.shortcuts import render
from django.views import View
from django_redis import get_redis_connection
from . import constants
from meiduo_mall.libs.captcha.captcha import captcha


class ImagecodeView(View):
    def get(self,request,uuid):
        text,code,image = captcha.generate_captcha()
        print(code)
        redis_cli = get_redis_connection('verify_code')
        redis_cli.setex(uuid,constants.IMAGE_CODE_EXPIRES,code)
        return HttpResponse(image,content_type='image/png')




